New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

platform-folders

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

platform-folders

Module to get platform dependent folders (e.g. documents, downloads, config)

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
171
increased by25.74%
Maintainers
1
Weekly downloads
 
Created
Source

platform-folders

Node.js bindings for sago007/PlatformFolders (requires Node.js 8+)

This library is inspired by Electrons app.getPath used for getting so called "special directories". These directories, like "Documents", "Downloads" and "AppData" are platform dependent. This Node Native Addon uses a C++ libary (linked above) to resolve the paths on Windows, "Linux" and Mac OS X.

Usage

You can either use the "Electron-Style" by calling the default export:

import getPath from 'platform-folders';
console.log(getPath('downloads'));

Following names are supported:

  • home Home folder (e.g. /home/<Username>, c:\Users\<Username>, /Users/<Username>)
  • appData Per-User Application Directory (e.g. /home/<Username>/.local/share, c:\Users\<Username>\AppData\Roaming, /Users/<Username>/Library/Application Support)
  • userData Directory for storing config files (e.g. /home/<Username>/.config, c:\Users\<Username>\AppData\Roaming, /Users/<Username>/Library/Application Support)
  • desktop Desktop directory (e.g. /home/<Username>/Schreibtisch (on a German system), c:\Users\<Username>\Desktop, /Users/<Username>/Desktop)
  • documents Documents directory (e.g. /home/<Username>/Dokumente (on a German system), c:\Users\<Username>\Documents, /Users/<Username>/Documents)
  • Downloads Downloads directory (e.g. /home/<Username>/Downloads, c:\Users\<Username>\Downloads, /Users/<Username>/Downloads)
  • music Music directory (e.g. /home/<Username>/Musik (on a German system), c:\Users\<Username>\Music, /Users/<Username>/Music)
  • pictures Pictures directory (e.g. /home/<Username>/Bilder (on a German system), c:\Users\<Username>\Pictures, /Users/<Username>/Pictures)
  • videos Videos directory (e.g. /home/<Username>/Videos, c:\Users\<Username>\Videos, /Users/<Username>/Videos)
  • cache Cache directory (e.g. /home/<Username>/.cache, c:\Users\<Username>\AppData\Local, /Users/<Username>/Library/Caches)
  • savegames Directory for savegames (e.g. /home/<Username>/.local/share, c:\Users\<Username>\SavedGames, /Users/<Username>/Library/Application Support)

Alternatively you can use the named exports:

import {getDownloadsFolder} from 'platform-folders';
console.log(getDownloadsFolder());
KeyMethod
homegetHomeFolder()
appDatagetDataHome()
appdatagetDataHome()
userDatagetConfigHome()
desktopgetDesktopFolder()
documentsgetDocumentsFolder()
downloadsgetDownloadsFolder()
musicgetMusicFolder()
picturesgetPicturesFolder()
videosgetVideosFolder()
cachegetCacheFolder()
savegamesgetSaveGamesFolder()

Following paths can not be used with getPath (as they return arrays), but can be called using the exported function:

  • getDataFolders Additional global data folders (e.g. C:\ProgramData, /usr/share/)
  • getConfigFolders Additional global data folders (e.g. C:\ProgramData, /etc/xdg/)

These functions are not supported for OS X (they will return an empty array).

Keywords

FAQs

Package last updated on 17 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc